﻿using IdentityManagement.Localization;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
using Xms.Abp.Data;
using Xms.Abp.Settings;

namespace IdentityManagement;

public class IdentitySettings : ITransientDependency
{
    public int PasswordRequiredLength => 6;//6
    public int PasswordRequiredUniqueChars => 1;//1
    public bool PasswordRequireNonAlphanumeric => true;//true
    public bool PasswordRequireLowercase => true;//true
    public bool PasswordRequireUppercase => true;//true
    public bool PasswordRequireDigit => true;//true
    public bool LockoutAllowedForNewUsers => true;//true
    public int LockoutLockoutDuration => 5 * 60;//5*60
    public int LockoutMaxFailedAccessAttempts => 5;//5
    public bool SignInRequireConfirmedEmail => false;//false
    public bool SignInEnablePhoneNumberConfirmation => true;//true
    public bool SignInRequireConfirmedPhoneNumber => false;//false
    public bool UserIsUserNameUpdateEnabled => true;//true
    public bool UserIsEmailUpdateEnabled => true;//true
    public int OrganizationUnitMaxUserMembershipCount => int.MaxValue;//int.MaxValue
}

//[SettingsDefinition(TenantSettingsValueProvider.ProviderName, typeof(IdentityResource))]
//public class IdentitySettings: SettingsBase
//{
//    [SettingValue("6", valueType: DataType.Integer)]
//    public int PasswordRequiredLength => GetValue<int>();//6
//    [SettingValue("1", valueType: DataType.Integer)]
//    public int PasswordRequiredUniqueChars => GetValue<int>();//1
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool PasswordRequireNonAlphanumeric => GetValue<bool>();//true
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool PasswordRequireLowercase => GetValue<bool>();//true
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool PasswordRequireUppercase => GetValue<bool>();//true
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool PasswordRequireDigit => GetValue<bool>();//true
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool LockoutAllowedForNewUsers => GetValue<bool>();//true
//    [SettingValue("300", valueType: DataType.Integer)]
//    public int LockoutLockoutDuration => GetValue<int>();//5*60
//    [SettingValue("5", valueType: DataType.Integer)]
//    public int LockoutMaxFailedAccessAttempts => GetValue<int>();//5
//    [SettingValue("false", valueType: DataType.Boolean)]
//    public bool SignInRequireConfirmedEmail => GetValue<bool>();//false
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool SignInEnablePhoneNumberConfirmation => GetValue<bool>();//true
//    [SettingValue("false", valueType: DataType.Boolean)]
//    public bool SignInRequireConfirmedPhoneNumber => GetValue<bool>();//false
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool UserIsUserNameUpdateEnabled => GetValue<bool>();//true
//    [SettingValue("true", valueType: DataType.Boolean)]
//    public bool UserIsEmailUpdateEnabled => GetValue<bool>();//true
//    [SettingValue("2147483647", valueType: DataType.Integer)]
//    public int OrganizationUnitMaxUserMembershipCount => GetValue<int>();//int.MaxValue
//}
//public class AbpIdentitySettingDefinitionProvider : SettingDefinitionProvider
//{
//    public override void Define(ISettingDefinitionContext context)
//    {
//        context.Add(
//            new SettingDefinition(
//                IdentitySettingNames.Password.RequiredLength,
//                6.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequiredLength"),
//                L("Description:Abp.Identity.Password.RequiredLength"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Password.RequiredUniqueChars,
//                1.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequiredUniqueChars"),
//                L("Description:Abp.Identity.Password.RequiredUniqueChars"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Password.RequireNonAlphanumeric,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequireNonAlphanumeric"),
//                L("Description:Abp.Identity.Password.RequireNonAlphanumeric"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Password.RequireLowercase,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequireLowercase"),
//                L("Description:Abp.Identity.Password.RequireLowercase"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Password.RequireUppercase,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequireUppercase"),
//                L("Description:Abp.Identity.Password.RequireUppercase"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Password.RequireDigit,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.Password.RequireDigit"),
//                L("Description:Abp.Identity.Password.RequireDigit"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Lockout.AllowedForNewUsers,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.Lockout.AllowedForNewUsers"),
//                L("Description:Abp.Identity.Lockout.AllowedForNewUsers"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Lockout.LockoutDuration,
//                (5 * 60).ToString(),
//                L("DisplayName:Abp.Identity.Lockout.LockoutDuration"),
//                L("Description:Abp.Identity.Lockout.LockoutDuration"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.Lockout.MaxFailedAccessAttempts,
//                5.ToString(),
//                L("DisplayName:Abp.Identity.Lockout.MaxFailedAccessAttempts"),
//                L("Description:Abp.Identity.Lockout.MaxFailedAccessAttempts"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.SignIn.RequireConfirmedEmail,
//                false.ToString(),
//                L("DisplayName:Abp.Identity.SignIn.RequireConfirmedEmail"),
//                L("Description:Abp.Identity.SignIn.RequireConfirmedEmail"),
//                true),
//            new SettingDefinition(
//                IdentitySettingNames.SignIn.EnablePhoneNumberConfirmation,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation"),
//                L("Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation"),
//                true),
//            new SettingDefinition(
//                IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber,
//                false.ToString(),
//                L("DisplayName:Abp.Identity.SignIn.RequireConfirmedPhoneNumber"),
//                L("Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.User.IsUserNameUpdateEnabled,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.User.IsUserNameUpdateEnabled"),
//                L("Description:Abp.Identity.User.IsUserNameUpdateEnabled"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.User.IsEmailUpdateEnabled,
//                true.ToString(),
//                L("DisplayName:Abp.Identity.User.IsEmailUpdateEnabled"),
//                L("Description:Abp.Identity.User.IsEmailUpdateEnabled"),
//                true),

//            new SettingDefinition(
//                IdentitySettingNames.OrganizationUnit.MaxUserMembershipCount,
//                int.MaxValue.ToString(),
//                L("Identity.OrganizationUnit.MaxUserMembershipCount"),
//                L("Identity.OrganizationUnit.MaxUserMembershipCount"),
//                true)
//        );
//    }

//    private static LocalizableString L(string name)
//    {
//        return LocalizableString.Create<IdentityResource>(name);
//    }
//}
